package com.cowmooed;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;

import java.net.UnknownHostException;

@SpringBootApplication
@Slf4j
public class BackCodeApplication {

    public static void main(String[] args) throws UnknownHostException {
        ConfigurableApplicationContext application = SpringApplication.run(BackCodeApplication.class, args);
        Environment env = application.getEnvironment();
        
        // 获取服务器端口和上下文路径
        String port = env.getProperty("server.port", "8080");
        String contextPath = env.getProperty("server.servlet.context-path", "");
        
        // 输出Swagger文档访问地址
        log.info("\n----------------------------------------------------------\n\t"
                + "应用启动成功! 访问链接:\n\t"
                + "Swagger文档: \t\thttp://localhost:{}{}/swagger-ui/index.html\n"
                + "----------------------------------------------------------",
                port, contextPath);
    }

}
